<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<html>
<head>
	<base href="${pageContext.request.contextPath}/">
<title>毕业设计项目</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/style.css" rel="stylesheet" type="text/css">
<script src="script/common.js"></script>
</head>
<body>

<div class="page_title">客户服务管理 > 服务分配</div>
<form method="post" action="CusService/selectService?path=dispatch	">
<div class="button_bar">
	<button class="common_button" onclick="help('');">帮助</button>
	<button class="common_button" type="submit">查询</button>
</div>
<table class="query_form_table" height="53">
	<tr>
		<th height="28">客户</th>
		<td><input name="svrCustName" value="${cstServiceLast.svrCustName}"/></td>
		<th height="28">概要</th>
		<td><input name="svrTitle" value="${cstServiceLast.svrTitle}"/></td>
		<th height="28">服务类型</th>
		<td>
			<select name="svrType">
				<option value=''>全部</option>
				<option value="1">咨询</option>
				<option value="2">建议</option>
				<option value="3">投诉</option>
			</select>
		</td>
	</tr>
	<tr>
		<th height="22">创建日期</th>
		<td colspan="3">
			<input name="date1" size="10" type="date" value="${cstServiceLast.svrCreateDate}"/>
			-
			<input name="date2" size="10" type="date" value="${cstServiceLast.svrDueDate}"/>
		</td>
		<th height="22">状态</th>
		<td>
			<select name="svrStatus">
				<option selected>新创建</option>
			</select>
		</td>
	</tr>
</table>
</form>
<br />
<table class="data_list_table">
	<tr>
		<th>编号</th>
		<th>客户</th>
		<th>概要</th>
		<th>服务类型</th>
		<th>创建人</th>
		<th>创建日期</th>
		<th>分配给</th>
		<th>操作</th>
	</tr>
	<c:forEach items="${cstServiceList}" var="cstService">
	<tr>
		<td class="list_data_number">${cstService.svrId}</td>
		<td class="list_data_text">${cstService.svrCustName}</td>
		<td class="list_data_ltext">${cstService.svrTitle}</td>
		<td class="list_data_text">${cstService.svrType=='1'?'咨询':(cstService.svrType=='2'?'建议':'投诉')}</td>
		<td class="list_data_text">${cstService.svrCreateBy}</td>
		<td class="list_data_text" name="tdate">${cstService.svrCreateDate}</td>
		<td class="list_data_text">
			<select  name="sysUser">
				<option disabled="disabled">请选择...</option>
			</select>
			<button class="common_button" onclick="reload();">分配</button>  
		</td>
		<td class="list_data_op">
			<img svrId="${cstService.svrId}" name="delete" title="删除" src="images/bt_del.gif" class="op_button" />
		</td>
	</tr>
	</c:forEach>
	<tr>
		<th colspan="8" class="pager">
			<div class="pager">
				共59条记录 每页<input value="10" size="2" />条
				第<input value="1" size="2"/>页/共5页
				<a href="#">第一页</a>
				<a href="#">上一页</a>
				<a href="#">下一页</a>
				<a href="#">最后一页</a>
				转到<input value="1" size="2" />页
				<button width="20" onclick="reload();">GO</button>
			</div>
		</th>
	</tr>
</table>
<script src="js/jquery-2.1.1.js"></script>
<script>
    $.post("CusService/selectAllUser",function (json) {
        console.log(json);
        var select=$("select[name='sysUser']");
        $.each(json,function (index,values) {
            var option=$("<option></option>");
            option.attr("value",values.usrId);
            option.text(values.usrName);
            select.append(option);
        });
    },"json");
    $("img[name='delete']").click(function () {
		$.ajax({
			url:"CusService/deleteService",
			data:{"svrId":$(this).attr("svrId")}
		});
        setTimeout(function(){
            location.reload();
        },1000);
    });

    $(function () {
        var d1=$("input[name='date1']");var d2=$("input[name='date2']");
        if(d1.val().length>0){
            var first=new Date(d1.val());
            var fdate=formatDate(first);
            console.log("f1:"+fdate);
            d1.val(fdate);
        }if(d2.val().length>0){
            var second=new Date(d2.val());
            d2.val(formatDate(second));
            console.log("s2:"+formatDate(second));
        }
        $("td[name='tdate']").each(function (index,value) {
			var thisTxt=parseInt($(this).text());
            var date=new Date(thisTxt);
            var fdate=toDDMMMYYYY(date);
			$(this).text(fdate);
        });
    });


</script>
</body>
</html>